<!DOCTYPE HTML>
<html class="butler">
<head>
    <title>科寓共享家</title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
    <style>
        .weui-col-33{
            border: none;
        }
        input{
            display: none;
        }
    </style>
</head>
<body ontouchstart="">
<form class="statuForm">
    <div class="weui-row weui-no-gutter customerTitle ">
        <div style="height: 50px;width: 20%">
            <a href="butlerUser.ejs" style="color: #FFFFFF"><img src="<%= global.config.publicPath %>/page/images/back.png" ></a>
            <span > <a href="butlerUser.ejs" style="color: #FFFFFF">返回</a></span>
        </div>
        <div  style="height: 50px;width: 60%">
            会员详情
        </div>
        <div  style="height: 50px;width: 20%">
            <span id="edit">编辑</span>
        </div>
    </div>
    <div class="info">
        <div class="circles"></div>
        <div class="names"><input class="weui_input underline" type="text" placeholder="用户名" name="name" value="<%= data.name %>" style="width: 10em"><span class="underline"><%= data.name %></span></div>
    </div>
    <div class="detail">

        <span class="stateIcon"></span>
        <p style="display: inline-block;color: #B299A5">基本信息</p>
        <div class="detailForm">
            <p>会员编号：<input class="weui_input underline" type="text" placeholder="请输入会员编号" name="code" value="<%= data.code %>" style="width: 10em"><span class="underline"><%= data.code %></span></p>
            <p>手机号码：<input class="weui_input underline" type="tel" placeholder="请输入手机号码" name="phone" value="<%= data.phone %>" style="width: 10em"><span class="underline"><%= data.phone %></span></p>
            <p>身份证号：<input class="weui_input underline" type="text" placeholder="请输入身份证号" name="idCard" value="<%= data.idCard %>" style="width: 10em"><span class="underline"><%= data.idCard %></span></p>
            <input type="hidden" name="id" value="<%=data.id%>">
        </div>
    </div>
    <div class="underline"></div>

    <div class="detail">

        <span class="stateIcon"></span>
        <p style="display: inline-block;color: #B299A5">个人信息</p>
        <div class="detailForm">
            <p>性别：<input class="weui_input underline" type="text" placeholder="选择用户性别" name="sex" value="<%= data.sex %>" id="sex" style="width: 10em"><span class="underline"><%= data.sex %></span></p>
        </div>
    </div>
    <div class="underline"></div>

    <div class="detail">

        <span class="stateIcon"></span>
        <p style="display: inline-block;color: #B299A5">状态信息</p>
        <div class="detailForm">
            <p>用户状态：<input class="weui_input underline" type="text" placeholder="选择用户状态" name="status" value="<%=data.status %>" id="status" style="width: 10em">
            <%
                let status=data.status;
                let setStatus;
                switch (status){
                    case 0:
                        setStatus='禁用';
                        break;
                    case 4:
                        setStatus='启用';
                        break;
                    case 3:
                        setStatus='新用户';
                        break;
                }
            %>
                <span class="underline"><%=setStatus%></span>
            </p>
            <p>认证状态：<input class="weui_input underline" type="text" placeholder="选择认证状态" name="certification" value="<%=data.certification %>" id="certification" style="width: 10em">
            <%
            let certification=data.certification;
            let certificationStatus;
            switch (certification){
                case '0':
                    certificationStatus='未验证';
                    break;
                case '1':
                    certificationStatus='审核中';
                    break;
                case '2':
                    certificationStatus='通过验证';
                    break;
            }
            %>
                <span class="underline"><%=certificationStatus%></span>
            </p>
            <p>创建时间：<span class="underline"><%= data.createdDate %></span></p>
        </div>
    </div>
    <div class="underline"></div>
</form>

<a href="javascript:void(0);" class="weui_btn  weui_btn_default " id="sub" style="background-color: #0e90d2;display: none;">保存</a>
<% include common/footer.ejs %>
<script src="<%= global.config.publicPath %>/Swiper/3.3.1/js/swiper.jquery.<%= global.config.mode %>js"></script>
</body>
<script>
    'use strict';
    $(".swiper-container").swiper({
        loop: true,
        autoplay: 5000,
        paginationType:	'bullets',
        paginationHide:false,
        pagination:'.swiper-pagination'

    });
    //修改会员状态
    $('document').ready(function () {
        $('#certification').val(`<%=data.certification%>`);
        $('#status').val(`<%=data.status%>`);
    })
    $('#sub').click(function () {
        console.log('---------submit begin--------')
        let data = Dolphin.form.getValue('.statuForm');
        let dataStatus=$('#status').data('values');
        if(dataStatus==undefined){
            data.status = $('#status').val();
        }else{
            data.status = $('#status').data('values');
        }
        let dataCertification=$('#certification').data('values');
        if(dataCertification==undefined){
            data.certification = $('#certification').val();
        }else{
            data.certification = $('#certification').data('values');
        }
        console.log(data);
        console.log('---------use method--------')
        Dolphin.ajax({
            url: CTX +'/api/8f7def63cc5845468b2c65a69abb0664',
            type: 'put',
            data: Dolphin.json2string(data),
            forceUrl: 'true',
            onSuccess: function (reData) {
                console.log("-----------success-----------");
                console.log(reData);
                $.toast("操作成功");
                location.reload();
            }
        });
    });
    $('#edit').click(function () {
        $('#sub').css({"display":"block"});
        $('.underline').css({"display":"none"});
        $('input').css({"display":"inline-block"});

    })

    $("#sex").select({
        title: "性别",
        items: [
            {
                title: "男",
                value: "男",
            },
            {
                title: "女",
                value: "女",
            }
        ]
    });
    $("#status").select({
        title: "会员状态",
        items: [
            {
                title: "禁用",
                value: 0
            },
            {
                title: "启用",
                value: 4
            }
        ]
    });
    $("#certification").select({
        title: "认证状态",
        items: [
            {
                title: "未认证",
                value: 0
            },
            {
                title: "审核中",
                value: 1
            },
            {
                title: "通过验证",
                value: 2
            }
        ]
    });
</script>
</html>